<?php

namespace Api\Model;

use Think\Model;
use Think\Log;
class CarModel extends Model {

    protected $tableName = 'car';
    protected $pk = 'id';

    /**
     * 登录验证
     */
    public function login($mobile, $password) {
        //查询帐号

        $r = $this->where(array('mobile' => $mobile))->field('id,name,password,encrypt,'
                . 'mobile,load,carno')->where('status=0')->find();


        if (!$r) {
            return false;
        }
        $pass = password($password,$r['encrypt']);
        if ($r['password'] != $pass) {
            Log::write($pass, Log::INFO);
            return false;
        }
        unset($r['password']);
        unset($r['encrypt']);
        return $r;
    }

}
